<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.15"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>MNN: include/Tensor.hpp 源文件</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">MNN
   &#160;<span id="projectnumber">1.0</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- 制作者 Doxygen 1.8.15 -->
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',false,false,'search.php','搜索');
});
/* @license-end */</script>
<div id="main-nav"></div>
<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_d44c64559bbebec7f509842c48db8b23.html">include</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">Tensor.hpp</div>  </div>
</div><!--header-->
<div class="contents">
<a href="_tensor_8hpp.html">浏览该文件的文档.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="comment">//</span></div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="comment">//  Tensor.hpp</span></div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;<span class="comment">//  MNN</span></div><div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="comment">//</span></div><div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;<span class="comment">//  Created by MNN on 2018/08/14.</span></div><div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;<span class="comment">//  Copyright © 2018, Alibaba Group Holding Limited</span></div><div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;<span class="comment">//</span></div><div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;</div><div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;<span class="preprocessor">#ifndef Tensor_hpp</span></div><div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;<span class="preprocessor">#define Tensor_hpp</span></div><div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;</div><div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;<span class="preprocessor">#include &lt;vector&gt;</span></div><div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="_halide_runtime_8h.html">HalideRuntime.h</a>&quot;</span></div><div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="_m_n_n_define_8h.html">MNNDefine.h</a>&quot;</span></div><div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;</div><div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;<span class="keyword">namespace </span><a class="code" href="namespace_m_n_n.html">MNN</a> {</div><div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;</div><div class="line"><a name="l00025"></a><span class="lineno"><a class="line" href="class_m_n_n_1_1_tensor.html">   25</a></span>&#160;<span class="keyword">class </span><a class="code" href="_m_n_n_define_8h.html#a692428e2a0af8ffb79376d223a0695ab">MNN_PUBLIC</a> <a class="code" href="class_m_n_n_1_1_tensor.html">Tensor</a> {</div><div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;<span class="keyword">public</span>:</div><div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160;    <span class="keyword">struct </span>InsideDescribe;</div><div class="line"><a name="l00028"></a><span class="lineno">   28</span>&#160;</div><div class="line"><a name="l00030"></a><span class="lineno"><a class="line" href="class_m_n_n_1_1_tensor.html#a1a270092aad286acb9b3112a395ebd56">   30</a></span>&#160;    <span class="keyword">enum</span> <a class="code" href="class_m_n_n_1_1_tensor.html#a1a270092aad286acb9b3112a395ebd56">DimensionType</a> {</div><div class="line"><a name="l00032"></a><span class="lineno"><a class="line" href="class_m_n_n_1_1_tensor.html#a1a270092aad286acb9b3112a395ebd56a2e15384aba40fa633bdac31ea6114ff0">   32</a></span>&#160;        <a class="code" href="class_m_n_n_1_1_tensor.html#a1a270092aad286acb9b3112a395ebd56a2e15384aba40fa633bdac31ea6114ff0">TENSORFLOW</a>,</div><div class="line"><a name="l00034"></a><span class="lineno"><a class="line" href="class_m_n_n_1_1_tensor.html#a1a270092aad286acb9b3112a395ebd56a0075eb881e1bf0f0e4e47b6d2c09c409">   34</a></span>&#160;        <a class="code" href="class_m_n_n_1_1_tensor.html#a1a270092aad286acb9b3112a395ebd56a0075eb881e1bf0f0e4e47b6d2c09c409">CAFFE</a>,</div><div class="line"><a name="l00036"></a><span class="lineno"><a class="line" href="class_m_n_n_1_1_tensor.html#a1a270092aad286acb9b3112a395ebd56aee9d6efa4285615bbb6a799ea831f62e">   36</a></span>&#160;        CAFFE_C4</div><div class="line"><a name="l00037"></a><span class="lineno">   37</span>&#160;    };</div><div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;</div><div class="line"><a name="l00040"></a><span class="lineno"><a class="line" href="class_m_n_n_1_1_tensor.html#a1a7b058a27868208a3a10a61ae74051c">   40</a></span>&#160;    <span class="keyword">enum</span> <a class="code" href="class_m_n_n_1_1_tensor.html#a1a7b058a27868208a3a10a61ae74051c">HandleDataType</a> {</div><div class="line"><a name="l00042"></a><span class="lineno"><a class="line" href="class_m_n_n_1_1_tensor.html#a1a7b058a27868208a3a10a61ae74051ca2f46c5fa96e1f0de21aaf29bc2e0421b">   42</a></span>&#160;        HANDLE_NONE = 0,</div><div class="line"><a name="l00044"></a><span class="lineno"><a class="line" href="class_m_n_n_1_1_tensor.html#a1a7b058a27868208a3a10a61ae74051ca27a049e2f1db85abc9f803addb518a52">   44</a></span>&#160;        HANDLE_STRING = 1</div><div class="line"><a name="l00045"></a><span class="lineno">   45</span>&#160;    };</div><div class="line"><a name="l00046"></a><span class="lineno">   46</span>&#160;</div><div class="line"><a name="l00048"></a><span class="lineno"><a class="line" href="class_m_n_n_1_1_tensor.html#a1fa4cb1d96822754ca18a838fdc3ad03">   48</a></span>&#160;    <span class="keyword">enum</span> <a class="code" href="class_m_n_n_1_1_tensor.html#a1fa4cb1d96822754ca18a838fdc3ad03">DataReorderType</a> {</div><div class="line"><a name="l00050"></a><span class="lineno"><a class="line" href="class_m_n_n_1_1_tensor.html#a1fa4cb1d96822754ca18a838fdc3ad03a68b82f5cd23f37cdfcf966667c09b44e">   50</a></span>&#160;        NO_REORDER = 0,</div><div class="line"><a name="l00052"></a><span class="lineno"><a class="line" href="class_m_n_n_1_1_tensor.html#a1fa4cb1d96822754ca18a838fdc3ad03af77dd834f695e8ece3d80a6d21fe5b0d">   52</a></span>&#160;        REORDER_4 = 1,</div><div class="line"><a name="l00054"></a><span class="lineno"><a class="line" href="class_m_n_n_1_1_tensor.html#a1fa4cb1d96822754ca18a838fdc3ad03a25762a64b006ba9584a919a74bd7b49f">   54</a></span>&#160;        REORDER_8</div><div class="line"><a name="l00055"></a><span class="lineno">   55</span>&#160;    };</div><div class="line"><a name="l00056"></a><span class="lineno">   56</span>&#160;</div><div class="line"><a name="l00057"></a><span class="lineno">   57</span>&#160;<span class="keyword">public</span>:</div><div class="line"><a name="l00063"></a><span class="lineno">   63</span>&#160;    <a class="code" href="class_m_n_n_1_1_tensor.html">Tensor</a>(<span class="keywordtype">int</span> dimSize = 4, DimensionType type = CAFFE);</div><div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;</div><div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;    <a class="code" href="class_m_n_n_1_1_tensor.html">Tensor</a>(<span class="keyword">const</span> <a class="code" href="class_m_n_n_1_1_tensor.html">Tensor</a>* tensor, DimensionType type = CAFFE, <span class="keywordtype">bool</span> allocMemory = <span class="keyword">true</span>);</div><div class="line"><a name="l00073"></a><span class="lineno">   73</span>&#160;</div><div class="line"><a name="l00075"></a><span class="lineno">   75</span>&#160;    ~<a class="code" href="class_m_n_n_1_1_tensor.html">Tensor</a>();</div><div class="line"><a name="l00076"></a><span class="lineno">   76</span>&#160;</div><div class="line"><a name="l00077"></a><span class="lineno">   77</span>&#160;<span class="keyword">private</span>:</div><div class="line"><a name="l00078"></a><span class="lineno">   78</span>&#160;    <span class="comment">// remove all assignment operator</span></div><div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160;    <a class="code" href="class_m_n_n_1_1_tensor.html">Tensor</a>(<span class="keyword">const</span> <a class="code" href="class_m_n_n_1_1_tensor.html">Tensor</a>&amp; tensor)  = <span class="keyword">delete</span>;</div><div class="line"><a name="l00080"></a><span class="lineno">   80</span>&#160;    <a class="code" href="class_m_n_n_1_1_tensor.html">Tensor</a>(<span class="keyword">const</span> <a class="code" href="class_m_n_n_1_1_tensor.html">Tensor</a>&amp;&amp; tensor) = <span class="keyword">delete</span>;</div><div class="line"><a name="l00081"></a><span class="lineno">   81</span>&#160;    <a class="code" href="class_m_n_n_1_1_tensor.html">Tensor</a>&amp; operator=(<span class="keyword">const</span> <a class="code" href="class_m_n_n_1_1_tensor.html">Tensor</a>&amp;) = <span class="keyword">delete</span>;</div><div class="line"><a name="l00082"></a><span class="lineno">   82</span>&#160;    <a class="code" href="class_m_n_n_1_1_tensor.html">Tensor</a>&amp; operator=(<span class="keyword">const</span> <a class="code" href="class_m_n_n_1_1_tensor.html">Tensor</a>&amp;&amp;) = <span class="keyword">delete</span>;</div><div class="line"><a name="l00083"></a><span class="lineno">   83</span>&#160;</div><div class="line"><a name="l00084"></a><span class="lineno">   84</span>&#160;<span class="keyword">public</span>:</div><div class="line"><a name="l00093"></a><span class="lineno">   93</span>&#160;    <span class="keyword">static</span> <a class="code" href="class_m_n_n_1_1_tensor.html">Tensor</a>* createDevice(<span class="keyword">const</span> std::vector&lt;int&gt;&amp; shape, <a class="code" href="structhalide__type__t.html">halide_type_t</a> type, DimensionType dimType = TENSORFLOW);</div><div class="line"><a name="l00094"></a><span class="lineno">   94</span>&#160;</div><div class="line"><a name="l00102"></a><span class="lineno">  102</span>&#160;    <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt;</div><div class="line"><a name="l00103"></a><span class="lineno"><a class="line" href="class_m_n_n_1_1_tensor.html#aa279b55e3b5d0e2dabbaaf74e3da3e3b">  103</a></span>&#160;    <span class="keyword">static</span> <a class="code" href="class_m_n_n_1_1_tensor.html">Tensor</a>* <a class="code" href="class_m_n_n_1_1_tensor.html#aa279b55e3b5d0e2dabbaaf74e3da3e3b">createDevice</a>(<span class="keyword">const</span> std::vector&lt;int&gt;&amp; shape, <a class="code" href="class_m_n_n_1_1_tensor.html#a1a270092aad286acb9b3112a395ebd56">DimensionType</a> dimType = TENSORFLOW) {</div><div class="line"><a name="l00104"></a><span class="lineno">  104</span>&#160;        <span class="keywordflow">return</span> createDevice(shape, halide_type_of&lt;T&gt;(), dimType);</div><div class="line"><a name="l00105"></a><span class="lineno">  105</span>&#160;    }</div><div class="line"><a name="l00106"></a><span class="lineno">  106</span>&#160;</div><div class="line"><a name="l00115"></a><span class="lineno">  115</span>&#160;    <span class="keyword">static</span> <a class="code" href="class_m_n_n_1_1_tensor.html">Tensor</a>* create(<span class="keyword">const</span> std::vector&lt;int&gt;&amp; shape, <a class="code" href="structhalide__type__t.html">halide_type_t</a> type, <span class="keywordtype">void</span>* data = NULL,</div><div class="line"><a name="l00116"></a><span class="lineno">  116</span>&#160;                          DimensionType dimType = TENSORFLOW);</div><div class="line"><a name="l00117"></a><span class="lineno">  117</span>&#160;</div><div class="line"><a name="l00125"></a><span class="lineno">  125</span>&#160;    <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt;</div><div class="line"><a name="l00126"></a><span class="lineno"><a class="line" href="class_m_n_n_1_1_tensor.html#aea2d0916fda8cef1fa641c23807a3b5c">  126</a></span>&#160;    <span class="keyword">static</span> <a class="code" href="class_m_n_n_1_1_tensor.html">Tensor</a>* <a class="code" href="class_m_n_n_1_1_tensor.html#aea2d0916fda8cef1fa641c23807a3b5c">create</a>(<span class="keyword">const</span> std::vector&lt;int&gt;&amp; shape, <span class="keywordtype">void</span>* data = NULL, <a class="code" href="class_m_n_n_1_1_tensor.html#a1a270092aad286acb9b3112a395ebd56">DimensionType</a> dimType = TENSORFLOW) {</div><div class="line"><a name="l00127"></a><span class="lineno">  127</span>&#160;        <span class="keywordflow">return</span> create(shape, halide_type_of&lt;T&gt;(), data, dimType);</div><div class="line"><a name="l00128"></a><span class="lineno">  128</span>&#160;    }</div><div class="line"><a name="l00129"></a><span class="lineno">  129</span>&#160;</div><div class="line"><a name="l00130"></a><span class="lineno">  130</span>&#160;<span class="keyword">public</span>:</div><div class="line"><a name="l00136"></a><span class="lineno">  136</span>&#160;    <span class="keywordtype">bool</span> copyFromHostTensor(<span class="keyword">const</span> <a class="code" href="class_m_n_n_1_1_tensor.html">Tensor</a>* hostTensor);</div><div class="line"><a name="l00137"></a><span class="lineno">  137</span>&#160;</div><div class="line"><a name="l00143"></a><span class="lineno">  143</span>&#160;    <span class="keywordtype">bool</span> copyToHostTensor(<a class="code" href="class_m_n_n_1_1_tensor.html">Tensor</a>* hostTensor) <span class="keyword">const</span>;</div><div class="line"><a name="l00144"></a><span class="lineno">  144</span>&#160;</div><div class="line"><a name="l00151"></a><span class="lineno">  151</span>&#160;    <span class="keyword">static</span> <a class="code" href="class_m_n_n_1_1_tensor.html">Tensor</a>* createHostTensorFromDevice(<span class="keyword">const</span> <a class="code" href="class_m_n_n_1_1_tensor.html">Tensor</a>* deviceTensor, <span class="keywordtype">bool</span> copyData = <span class="keyword">true</span>);</div><div class="line"><a name="l00152"></a><span class="lineno">  152</span>&#160;</div><div class="line"><a name="l00153"></a><span class="lineno">  153</span>&#160;<span class="keyword">public</span>:</div><div class="line"><a name="l00154"></a><span class="lineno"><a class="line" href="class_m_n_n_1_1_tensor.html#aa26783eaf35d8a554a4221f37d06e70a">  154</a></span>&#160;    <span class="keyword">const</span> <a class="code" href="structhalide__buffer__t.html">halide_buffer_t</a>&amp; <a class="code" href="class_m_n_n_1_1_tensor.html#aa26783eaf35d8a554a4221f37d06e70a">buffer</a>()<span class="keyword"> const </span>{</div><div class="line"><a name="l00155"></a><span class="lineno">  155</span>&#160;        <span class="keywordflow">return</span> mBuffer;</div><div class="line"><a name="l00156"></a><span class="lineno">  156</span>&#160;    }</div><div class="line"><a name="l00157"></a><span class="lineno"><a class="line" href="class_m_n_n_1_1_tensor.html#ab08fdc1ae9e677da39a9e23497ab34a1">  157</a></span>&#160;    <a class="code" href="structhalide__buffer__t.html">halide_buffer_t</a>&amp; <a class="code" href="class_m_n_n_1_1_tensor.html#ab08fdc1ae9e677da39a9e23497ab34a1">buffer</a>() {</div><div class="line"><a name="l00158"></a><span class="lineno">  158</span>&#160;        <span class="keywordflow">return</span> mBuffer;</div><div class="line"><a name="l00159"></a><span class="lineno">  159</span>&#160;    }</div><div class="line"><a name="l00160"></a><span class="lineno">  160</span>&#160;</div><div class="line"><a name="l00165"></a><span class="lineno">  165</span>&#160;    DimensionType getDimensionType() <span class="keyword">const</span>;</div><div class="line"><a name="l00166"></a><span class="lineno">  166</span>&#160;</div><div class="line"><a name="l00171"></a><span class="lineno">  171</span>&#160;    HandleDataType getHandleDataType() <span class="keyword">const</span>;</div><div class="line"><a name="l00172"></a><span class="lineno">  172</span>&#160;</div><div class="line"><a name="l00177"></a><span class="lineno">  177</span>&#160;    <span class="keywordtype">void</span> setType(<span class="keywordtype">int</span> type);</div><div class="line"><a name="l00178"></a><span class="lineno">  178</span>&#160;</div><div class="line"><a name="l00183"></a><span class="lineno"><a class="line" href="class_m_n_n_1_1_tensor.html#a8c1a87ef0b47e372f42fe627747acf76">  183</a></span>&#160;    <span class="keyword">inline</span> <a class="code" href="structhalide__type__t.html">halide_type_t</a> <a class="code" href="class_m_n_n_1_1_tensor.html#a8c1a87ef0b47e372f42fe627747acf76">getType</a>()<span class="keyword"> const </span>{</div><div class="line"><a name="l00184"></a><span class="lineno">  184</span>&#160;        <span class="keywordflow">return</span> mBuffer.type;</div><div class="line"><a name="l00185"></a><span class="lineno">  185</span>&#160;    }</div><div class="line"><a name="l00186"></a><span class="lineno">  186</span>&#160;</div><div class="line"><a name="l00191"></a><span class="lineno">  191</span>&#160;    <span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt;</div><div class="line"><a name="l00192"></a><span class="lineno"><a class="line" href="class_m_n_n_1_1_tensor.html#abc30b060584e20059369acc3cb88d073">  192</a></span>&#160;    T* <a class="code" href="class_m_n_n_1_1_tensor.html#abc30b060584e20059369acc3cb88d073">host</a>()<span class="keyword"> const </span>{</div><div class="line"><a name="l00193"></a><span class="lineno">  193</span>&#160;        <span class="keywordflow">return</span> (T*)mBuffer.host;</div><div class="line"><a name="l00194"></a><span class="lineno">  194</span>&#160;    }</div><div class="line"><a name="l00195"></a><span class="lineno">  195</span>&#160;</div><div class="line"><a name="l00200"></a><span class="lineno"><a class="line" href="class_m_n_n_1_1_tensor.html#a79200212a531a64e861f87f394077889">  200</a></span>&#160;    uint64_t <a class="code" href="class_m_n_n_1_1_tensor.html#a79200212a531a64e861f87f394077889">deviceId</a>()<span class="keyword"> const </span>{</div><div class="line"><a name="l00201"></a><span class="lineno">  201</span>&#160;        <span class="keywordflow">return</span> mBuffer.device;</div><div class="line"><a name="l00202"></a><span class="lineno">  202</span>&#160;    }</div><div class="line"><a name="l00203"></a><span class="lineno">  203</span>&#160;</div><div class="line"><a name="l00204"></a><span class="lineno">  204</span>&#160;<span class="keyword">public</span>:</div><div class="line"><a name="l00205"></a><span class="lineno"><a class="line" href="class_m_n_n_1_1_tensor.html#a048c5b3e7287526a825948fc1d9bf8fb">  205</a></span>&#160;    <span class="keywordtype">int</span> <a class="code" href="class_m_n_n_1_1_tensor.html#a048c5b3e7287526a825948fc1d9bf8fb">dimensions</a>()<span class="keyword"> const </span>{</div><div class="line"><a name="l00206"></a><span class="lineno">  206</span>&#160;        <span class="keywordflow">return</span> mBuffer.dimensions;</div><div class="line"><a name="l00207"></a><span class="lineno">  207</span>&#160;    }</div><div class="line"><a name="l00208"></a><span class="lineno">  208</span>&#160;</div><div class="line"><a name="l00213"></a><span class="lineno">  213</span>&#160;    std::vector&lt;int&gt; shape() <span class="keyword">const</span>;</div><div class="line"><a name="l00214"></a><span class="lineno">  214</span>&#160;</div><div class="line"><a name="l00219"></a><span class="lineno">  219</span>&#160;    <span class="keywordtype">int</span> size() <span class="keyword">const</span>;</div><div class="line"><a name="l00220"></a><span class="lineno">  220</span>&#160;</div><div class="line"><a name="l00225"></a><span class="lineno"><a class="line" href="class_m_n_n_1_1_tensor.html#a324f5b9156ba3994afbf355255db1b85">  225</a></span>&#160;    <span class="keyword">inline</span> <span class="keywordtype">int</span> <a class="code" href="class_m_n_n_1_1_tensor.html#a324f5b9156ba3994afbf355255db1b85">elementSize</a>()<span class="keyword"> const </span>{</div><div class="line"><a name="l00226"></a><span class="lineno">  226</span>&#160;        <span class="keywordflow">return</span> size() / mBuffer.type.bytes();</div><div class="line"><a name="l00227"></a><span class="lineno">  227</span>&#160;    }</div><div class="line"><a name="l00228"></a><span class="lineno">  228</span>&#160;</div><div class="line"><a name="l00229"></a><span class="lineno">  229</span>&#160;<span class="keyword">public</span>:</div><div class="line"><a name="l00230"></a><span class="lineno">  230</span>&#160;    <span class="comment">// for CAFFE tensors only.</span></div><div class="line"><a name="l00231"></a><span class="lineno"><a class="line" href="class_m_n_n_1_1_tensor.html#ad55d96559751d5eabc5de9776b5d9151">  231</a></span>&#160;    <span class="keyword">inline</span> <span class="keywordtype">int</span> <a class="code" href="class_m_n_n_1_1_tensor.html#ad55d96559751d5eabc5de9776b5d9151">width</a>()<span class="keyword"> const </span>{</div><div class="line"><a name="l00232"></a><span class="lineno">  232</span>&#160;        <span class="keywordflow">return</span> mBuffer.dim[3].extent;</div><div class="line"><a name="l00233"></a><span class="lineno">  233</span>&#160;    }</div><div class="line"><a name="l00234"></a><span class="lineno"><a class="line" href="class_m_n_n_1_1_tensor.html#a10f9cd60e6c5423d90dfb3025d4d60c7">  234</a></span>&#160;    <span class="keyword">inline</span> <span class="keywordtype">int</span> <a class="code" href="class_m_n_n_1_1_tensor.html#a10f9cd60e6c5423d90dfb3025d4d60c7">height</a>()<span class="keyword"> const </span>{</div><div class="line"><a name="l00235"></a><span class="lineno">  235</span>&#160;        <span class="keywordflow">return</span> mBuffer.dim[2].extent;</div><div class="line"><a name="l00236"></a><span class="lineno">  236</span>&#160;    }</div><div class="line"><a name="l00237"></a><span class="lineno"><a class="line" href="class_m_n_n_1_1_tensor.html#abbf49c308f681e0f9e416476b72be0d9">  237</a></span>&#160;    <span class="keyword">inline</span> <span class="keywordtype">int</span> <a class="code" href="class_m_n_n_1_1_tensor.html#abbf49c308f681e0f9e416476b72be0d9">channel</a>()<span class="keyword"> const </span>{</div><div class="line"><a name="l00238"></a><span class="lineno">  238</span>&#160;        <span class="keywordflow">return</span> mBuffer.dim[1].extent;</div><div class="line"><a name="l00239"></a><span class="lineno">  239</span>&#160;    }</div><div class="line"><a name="l00240"></a><span class="lineno"><a class="line" href="class_m_n_n_1_1_tensor.html#abf36a5bb25335dcfab95c687b4090bee">  240</a></span>&#160;    <span class="keyword">inline</span> <span class="keywordtype">int</span> <a class="code" href="class_m_n_n_1_1_tensor.html#abf36a5bb25335dcfab95c687b4090bee">batch</a>()<span class="keyword"> const </span>{</div><div class="line"><a name="l00241"></a><span class="lineno">  241</span>&#160;        <span class="keywordflow">return</span> mBuffer.dim[0].extent;</div><div class="line"><a name="l00242"></a><span class="lineno">  242</span>&#160;    }</div><div class="line"><a name="l00243"></a><span class="lineno">  243</span>&#160;</div><div class="line"><a name="l00244"></a><span class="lineno">  244</span>&#160;    <span class="comment">// for TENSORFLOW tensors only.</span></div><div class="line"><a name="l00245"></a><span class="lineno"><a class="line" href="class_m_n_n_1_1_tensor.html#a4996312c75e4e664af9e8b93369ae3b6">  245</a></span>&#160;    <span class="keyword">inline</span> <span class="keywordtype">int</span> <a class="code" href="class_m_n_n_1_1_tensor.html#a4996312c75e4e664af9e8b93369ae3b6">tfWidth</a>()<span class="keyword"> const </span>{</div><div class="line"><a name="l00246"></a><span class="lineno">  246</span>&#160;        <span class="keywordflow">return</span> mBuffer.dim[2].extent;</div><div class="line"><a name="l00247"></a><span class="lineno">  247</span>&#160;    }</div><div class="line"><a name="l00248"></a><span class="lineno"><a class="line" href="class_m_n_n_1_1_tensor.html#aed0c48473214bf9596bab3235918497f">  248</a></span>&#160;    <span class="keyword">inline</span> <span class="keywordtype">int</span> <a class="code" href="class_m_n_n_1_1_tensor.html#aed0c48473214bf9596bab3235918497f">tfHeight</a>()<span class="keyword"> const </span>{</div><div class="line"><a name="l00249"></a><span class="lineno">  249</span>&#160;        <span class="keywordflow">return</span> mBuffer.dim[1].extent;</div><div class="line"><a name="l00250"></a><span class="lineno">  250</span>&#160;    }</div><div class="line"><a name="l00251"></a><span class="lineno"><a class="line" href="class_m_n_n_1_1_tensor.html#a24be036d72e6680b92513090d541804f">  251</a></span>&#160;    <span class="keyword">inline</span> <span class="keywordtype">int</span> <a class="code" href="class_m_n_n_1_1_tensor.html#a24be036d72e6680b92513090d541804f">tfChannel</a>()<span class="keyword"> const </span>{</div><div class="line"><a name="l00252"></a><span class="lineno">  252</span>&#160;        <span class="keywordflow">return</span> mBuffer.dim[3].extent;</div><div class="line"><a name="l00253"></a><span class="lineno">  253</span>&#160;    }</div><div class="line"><a name="l00254"></a><span class="lineno"><a class="line" href="class_m_n_n_1_1_tensor.html#a3fc95b1ca0cdf43aa6a77890c52a86a6">  254</a></span>&#160;    <span class="keyword">inline</span> <span class="keywordtype">int</span> <a class="code" href="class_m_n_n_1_1_tensor.html#a3fc95b1ca0cdf43aa6a77890c52a86a6">tfBatch</a>()<span class="keyword"> const </span>{</div><div class="line"><a name="l00255"></a><span class="lineno">  255</span>&#160;        <span class="keywordflow">return</span> mBuffer.dim[0].extent;</div><div class="line"><a name="l00256"></a><span class="lineno">  256</span>&#160;    }</div><div class="line"><a name="l00257"></a><span class="lineno">  257</span>&#160;</div><div class="line"><a name="l00258"></a><span class="lineno">  258</span>&#160;    <span class="comment">// visit dimension&#39;s extent &amp; stride</span></div><div class="line"><a name="l00259"></a><span class="lineno"><a class="line" href="class_m_n_n_1_1_tensor.html#aae201441d5f9ddbc6311f7945e1b71e5">  259</a></span>&#160;    <span class="keyword">inline</span> <span class="keywordtype">int</span> <a class="code" href="class_m_n_n_1_1_tensor.html#aae201441d5f9ddbc6311f7945e1b71e5">stride</a>(<span class="keywordtype">int</span> index)<span class="keyword"> const </span>{</div><div class="line"><a name="l00260"></a><span class="lineno">  260</span>&#160;        <span class="keywordflow">return</span> mBuffer.dim[index].stride;</div><div class="line"><a name="l00261"></a><span class="lineno">  261</span>&#160;    }</div><div class="line"><a name="l00262"></a><span class="lineno"><a class="line" href="class_m_n_n_1_1_tensor.html#ad815d5e2ffc23a7133de6f68feff28ee">  262</a></span>&#160;    <span class="keyword">inline</span> <span class="keywordtype">int</span> <a class="code" href="class_m_n_n_1_1_tensor.html#ad815d5e2ffc23a7133de6f68feff28ee">length</a>(<span class="keywordtype">int</span> index)<span class="keyword"> const </span>{</div><div class="line"><a name="l00263"></a><span class="lineno">  263</span>&#160;        <span class="keywordflow">return</span> mBuffer.dim[index].extent;</div><div class="line"><a name="l00264"></a><span class="lineno">  264</span>&#160;    }</div><div class="line"><a name="l00265"></a><span class="lineno"><a class="line" href="class_m_n_n_1_1_tensor.html#acbfb65c02f4f7b031dac80aa7dc8f9a1">  265</a></span>&#160;    <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="class_m_n_n_1_1_tensor.html#acbfb65c02f4f7b031dac80aa7dc8f9a1">setStride</a>(<span class="keywordtype">int</span> index, <span class="keywordtype">int</span> stride) {</div><div class="line"><a name="l00266"></a><span class="lineno">  266</span>&#160;        mBuffer.dim[index].stride = stride;</div><div class="line"><a name="l00267"></a><span class="lineno">  267</span>&#160;    }</div><div class="line"><a name="l00268"></a><span class="lineno"><a class="line" href="class_m_n_n_1_1_tensor.html#ab45e71dd654c30ede21032db4331100a">  268</a></span>&#160;    <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="class_m_n_n_1_1_tensor.html#ab45e71dd654c30ede21032db4331100a">setLength</a>(<span class="keywordtype">int</span> index, <span class="keywordtype">int</span> length) {</div><div class="line"><a name="l00269"></a><span class="lineno">  269</span>&#160;        mBuffer.dim[index].extent = length;</div><div class="line"><a name="l00270"></a><span class="lineno">  270</span>&#160;    }</div><div class="line"><a name="l00271"></a><span class="lineno">  271</span>&#160;</div><div class="line"><a name="l00272"></a><span class="lineno">  272</span>&#160;<span class="keyword">public</span>:</div><div class="line"><a name="l00276"></a><span class="lineno">  276</span>&#160;    <span class="keywordtype">void</span> print() <span class="keyword">const</span>;</div><div class="line"><a name="l00277"></a><span class="lineno">  277</span>&#160;</div><div class="line"><a name="l00278"></a><span class="lineno">  278</span>&#160;<span class="keyword">private</span>:</div><div class="line"><a name="l00279"></a><span class="lineno">  279</span>&#160;    <a class="code" href="structhalide__buffer__t.html">halide_buffer_t</a> mBuffer;</div><div class="line"><a name="l00280"></a><span class="lineno">  280</span>&#160;    <span class="keyword">struct </span>InsideDescribe* mDescribe;</div><div class="line"><a name="l00281"></a><span class="lineno">  281</span>&#160;</div><div class="line"><a name="l00282"></a><span class="lineno">  282</span>&#160;<span class="keyword">private</span>:</div><div class="line"><a name="l00283"></a><span class="lineno"><a class="line" href="class_m_n_n_1_1_tensor.html#a64e8396ba37ccf60ea12a4c481609dca">  283</a></span>&#160;    <span class="keyword">friend</span> <span class="keyword">class </span>TensorUtils;</div><div class="line"><a name="l00284"></a><span class="lineno">  284</span>&#160;};</div><div class="line"><a name="l00285"></a><span class="lineno">  285</span>&#160;} <span class="comment">// namespace MNN</span></div><div class="line"><a name="l00286"></a><span class="lineno">  286</span>&#160;</div><div class="line"><a name="l00287"></a><span class="lineno">  287</span>&#160;<span class="preprocessor">#endif </span><span class="comment">/* Tensor_hpp */</span><span class="preprocessor"></span></div><div class="ttc" id="class_m_n_n_1_1_tensor_html_a324f5b9156ba3994afbf355255db1b85"><div class="ttname"><a href="class_m_n_n_1_1_tensor.html#a324f5b9156ba3994afbf355255db1b85">MNN::Tensor::elementSize</a></div><div class="ttdeci">int elementSize() const</div><div class="ttdoc">calculate number of elements needed to store data taking reordering flag into account.</div><div class="ttdef"><b>Definition:</b> Tensor.hpp:225</div></div>
<div class="ttc" id="class_m_n_n_1_1_tensor_html_abf36a5bb25335dcfab95c687b4090bee"><div class="ttname"><a href="class_m_n_n_1_1_tensor.html#abf36a5bb25335dcfab95c687b4090bee">MNN::Tensor::batch</a></div><div class="ttdeci">int batch() const</div><div class="ttdef"><b>Definition:</b> Tensor.hpp:240</div></div>
<div class="ttc" id="class_m_n_n_1_1_tensor_html_aa279b55e3b5d0e2dabbaaf74e3da3e3b"><div class="ttname"><a href="class_m_n_n_1_1_tensor.html#aa279b55e3b5d0e2dabbaaf74e3da3e3b">MNN::Tensor::createDevice</a></div><div class="ttdeci">static Tensor * createDevice(const std::vector&lt; int &gt; &amp;shape, DimensionType dimType=TENSORFLOW)</div><div class="ttdoc">create tensor with shape and dimension type. data type is represented by T.</div><div class="ttdef"><b>Definition:</b> Tensor.hpp:103</div></div>
<div class="ttc" id="class_m_n_n_1_1_tensor_html_a1a270092aad286acb9b3112a395ebd56a0075eb881e1bf0f0e4e47b6d2c09c409"><div class="ttname"><a href="class_m_n_n_1_1_tensor.html#a1a270092aad286acb9b3112a395ebd56a0075eb881e1bf0f0e4e47b6d2c09c409">MNN::Tensor::CAFFE</a></div><div class="ttdef"><b>Definition:</b> Tensor.hpp:34</div></div>
<div class="ttc" id="class_m_n_n_1_1_tensor_html_a1fa4cb1d96822754ca18a838fdc3ad03"><div class="ttname"><a href="class_m_n_n_1_1_tensor.html#a1fa4cb1d96822754ca18a838fdc3ad03">MNN::Tensor::DataReorderType</a></div><div class="ttdeci">DataReorderType</div><div class="ttdef"><b>Definition:</b> Tensor.hpp:48</div></div>
<div class="ttc" id="class_m_n_n_1_1_tensor_html_a3fc95b1ca0cdf43aa6a77890c52a86a6"><div class="ttname"><a href="class_m_n_n_1_1_tensor.html#a3fc95b1ca0cdf43aa6a77890c52a86a6">MNN::Tensor::tfBatch</a></div><div class="ttdeci">int tfBatch() const</div><div class="ttdef"><b>Definition:</b> Tensor.hpp:254</div></div>
<div class="ttc" id="class_m_n_n_1_1_tensor_html_a1a270092aad286acb9b3112a395ebd56a2e15384aba40fa633bdac31ea6114ff0"><div class="ttname"><a href="class_m_n_n_1_1_tensor.html#a1a270092aad286acb9b3112a395ebd56a2e15384aba40fa633bdac31ea6114ff0">MNN::Tensor::TENSORFLOW</a></div><div class="ttdef"><b>Definition:</b> Tensor.hpp:32</div></div>
<div class="ttc" id="class_m_n_n_1_1_tensor_html_ad55d96559751d5eabc5de9776b5d9151"><div class="ttname"><a href="class_m_n_n_1_1_tensor.html#ad55d96559751d5eabc5de9776b5d9151">MNN::Tensor::width</a></div><div class="ttdeci">int width() const</div><div class="ttdef"><b>Definition:</b> Tensor.hpp:231</div></div>
<div class="ttc" id="class_m_n_n_1_1_tensor_html_ab08fdc1ae9e677da39a9e23497ab34a1"><div class="ttname"><a href="class_m_n_n_1_1_tensor.html#ab08fdc1ae9e677da39a9e23497ab34a1">MNN::Tensor::buffer</a></div><div class="ttdeci">halide_buffer_t &amp; buffer()</div><div class="ttdef"><b>Definition:</b> Tensor.hpp:157</div></div>
<div class="ttc" id="class_m_n_n_1_1_tensor_html_ad815d5e2ffc23a7133de6f68feff28ee"><div class="ttname"><a href="class_m_n_n_1_1_tensor.html#ad815d5e2ffc23a7133de6f68feff28ee">MNN::Tensor::length</a></div><div class="ttdeci">int length(int index) const</div><div class="ttdef"><b>Definition:</b> Tensor.hpp:262</div></div>
<div class="ttc" id="class_m_n_n_1_1_tensor_html_ab45e71dd654c30ede21032db4331100a"><div class="ttname"><a href="class_m_n_n_1_1_tensor.html#ab45e71dd654c30ede21032db4331100a">MNN::Tensor::setLength</a></div><div class="ttdeci">void setLength(int index, int length)</div><div class="ttdef"><b>Definition:</b> Tensor.hpp:268</div></div>
<div class="ttc" id="class_m_n_n_1_1_tensor_html_a10f9cd60e6c5423d90dfb3025d4d60c7"><div class="ttname"><a href="class_m_n_n_1_1_tensor.html#a10f9cd60e6c5423d90dfb3025d4d60c7">MNN::Tensor::height</a></div><div class="ttdeci">int height() const</div><div class="ttdef"><b>Definition:</b> Tensor.hpp:234</div></div>
<div class="ttc" id="class_m_n_n_1_1_tensor_html_a4996312c75e4e664af9e8b93369ae3b6"><div class="ttname"><a href="class_m_n_n_1_1_tensor.html#a4996312c75e4e664af9e8b93369ae3b6">MNN::Tensor::tfWidth</a></div><div class="ttdeci">int tfWidth() const</div><div class="ttdef"><b>Definition:</b> Tensor.hpp:245</div></div>
<div class="ttc" id="class_m_n_n_1_1_tensor_html_aae201441d5f9ddbc6311f7945e1b71e5"><div class="ttname"><a href="class_m_n_n_1_1_tensor.html#aae201441d5f9ddbc6311f7945e1b71e5">MNN::Tensor::stride</a></div><div class="ttdeci">int stride(int index) const</div><div class="ttdef"><b>Definition:</b> Tensor.hpp:259</div></div>
<div class="ttc" id="_halide_runtime_8h_html"><div class="ttname"><a href="_halide_runtime_8h.html">HalideRuntime.h</a></div></div>
<div class="ttc" id="class_m_n_n_1_1_tensor_html"><div class="ttname"><a href="class_m_n_n_1_1_tensor.html">MNN::Tensor</a></div><div class="ttdef"><b>Definition:</b> Tensor.hpp:25</div></div>
<div class="ttc" id="class_m_n_n_1_1_tensor_html_abc30b060584e20059369acc3cb88d073"><div class="ttname"><a href="class_m_n_n_1_1_tensor.html#abc30b060584e20059369acc3cb88d073">MNN::Tensor::host</a></div><div class="ttdeci">T * host() const</div><div class="ttdoc">visit host memory, data type is represented by T.</div><div class="ttdef"><b>Definition:</b> Tensor.hpp:192</div></div>
<div class="ttc" id="_m_n_n_define_8h_html_a692428e2a0af8ffb79376d223a0695ab"><div class="ttname"><a href="_m_n_n_define_8h.html#a692428e2a0af8ffb79376d223a0695ab">MNN_PUBLIC</a></div><div class="ttdeci">#define MNN_PUBLIC</div><div class="ttdef"><b>Definition:</b> MNNDefine.h:53</div></div>
<div class="ttc" id="class_m_n_n_1_1_tensor_html_aa26783eaf35d8a554a4221f37d06e70a"><div class="ttname"><a href="class_m_n_n_1_1_tensor.html#aa26783eaf35d8a554a4221f37d06e70a">MNN::Tensor::buffer</a></div><div class="ttdeci">const halide_buffer_t &amp; buffer() const</div><div class="ttdef"><b>Definition:</b> Tensor.hpp:154</div></div>
<div class="ttc" id="class_m_n_n_1_1_tensor_html_a1a270092aad286acb9b3112a395ebd56"><div class="ttname"><a href="class_m_n_n_1_1_tensor.html#a1a270092aad286acb9b3112a395ebd56">MNN::Tensor::DimensionType</a></div><div class="ttdeci">DimensionType</div><div class="ttdef"><b>Definition:</b> Tensor.hpp:30</div></div>
<div class="ttc" id="class_m_n_n_1_1_tensor_html_a24be036d72e6680b92513090d541804f"><div class="ttname"><a href="class_m_n_n_1_1_tensor.html#a24be036d72e6680b92513090d541804f">MNN::Tensor::tfChannel</a></div><div class="ttdeci">int tfChannel() const</div><div class="ttdef"><b>Definition:</b> Tensor.hpp:251</div></div>
<div class="ttc" id="structhalide__type__t_html"><div class="ttname"><a href="structhalide__type__t.html">halide_type_t</a></div><div class="ttdef"><b>Definition:</b> HalideRuntime.h:82</div></div>
<div class="ttc" id="class_m_n_n_1_1_tensor_html_a8c1a87ef0b47e372f42fe627747acf76"><div class="ttname"><a href="class_m_n_n_1_1_tensor.html#a8c1a87ef0b47e372f42fe627747acf76">MNN::Tensor::getType</a></div><div class="ttdeci">halide_type_t getType() const</div><div class="ttdoc">get data type.</div><div class="ttdef"><b>Definition:</b> Tensor.hpp:183</div></div>
<div class="ttc" id="namespace_m_n_n_html"><div class="ttname"><a href="namespace_m_n_n.html">MNN</a></div><div class="ttdef"><b>Definition:</b> AutoTime.hpp:16</div></div>
<div class="ttc" id="class_m_n_n_1_1_tensor_html_acbfb65c02f4f7b031dac80aa7dc8f9a1"><div class="ttname"><a href="class_m_n_n_1_1_tensor.html#acbfb65c02f4f7b031dac80aa7dc8f9a1">MNN::Tensor::setStride</a></div><div class="ttdeci">void setStride(int index, int stride)</div><div class="ttdef"><b>Definition:</b> Tensor.hpp:265</div></div>
<div class="ttc" id="class_m_n_n_1_1_tensor_html_a048c5b3e7287526a825948fc1d9bf8fb"><div class="ttname"><a href="class_m_n_n_1_1_tensor.html#a048c5b3e7287526a825948fc1d9bf8fb">MNN::Tensor::dimensions</a></div><div class="ttdeci">int dimensions() const</div><div class="ttdef"><b>Definition:</b> Tensor.hpp:205</div></div>
<div class="ttc" id="class_m_n_n_1_1_tensor_html_abbf49c308f681e0f9e416476b72be0d9"><div class="ttname"><a href="class_m_n_n_1_1_tensor.html#abbf49c308f681e0f9e416476b72be0d9">MNN::Tensor::channel</a></div><div class="ttdeci">int channel() const</div><div class="ttdef"><b>Definition:</b> Tensor.hpp:237</div></div>
<div class="ttc" id="class_m_n_n_1_1_tensor_html_aed0c48473214bf9596bab3235918497f"><div class="ttname"><a href="class_m_n_n_1_1_tensor.html#aed0c48473214bf9596bab3235918497f">MNN::Tensor::tfHeight</a></div><div class="ttdeci">int tfHeight() const</div><div class="ttdef"><b>Definition:</b> Tensor.hpp:248</div></div>
<div class="ttc" id="structhalide__buffer__t_html"><div class="ttname"><a href="structhalide__buffer__t.html">halide_buffer_t</a></div><div class="ttdef"><b>Definition:</b> HalideRuntime.h:203</div></div>
<div class="ttc" id="class_m_n_n_1_1_tensor_html_a79200212a531a64e861f87f394077889"><div class="ttname"><a href="class_m_n_n_1_1_tensor.html#a79200212a531a64e861f87f394077889">MNN::Tensor::deviceId</a></div><div class="ttdeci">uint64_t deviceId() const</div><div class="ttdoc">visit device memory.</div><div class="ttdef"><b>Definition:</b> Tensor.hpp:200</div></div>
<div class="ttc" id="_m_n_n_define_8h_html"><div class="ttname"><a href="_m_n_n_define_8h.html">MNNDefine.h</a></div></div>
<div class="ttc" id="class_m_n_n_1_1_tensor_html_aea2d0916fda8cef1fa641c23807a3b5c"><div class="ttname"><a href="class_m_n_n_1_1_tensor.html#aea2d0916fda8cef1fa641c23807a3b5c">MNN::Tensor::create</a></div><div class="ttdeci">static Tensor * create(const std::vector&lt; int &gt; &amp;shape, void *data=NULL, DimensionType dimType=TENSORFLOW)</div><div class="ttdoc">create tensor with shape, data and dimension type. data type is represented by T.</div><div class="ttdef"><b>Definition:</b> Tensor.hpp:126</div></div>
<div class="ttc" id="class_m_n_n_1_1_tensor_html_a1a7b058a27868208a3a10a61ae74051c"><div class="ttname"><a href="class_m_n_n_1_1_tensor.html#a1a7b058a27868208a3a10a61ae74051c">MNN::Tensor::HandleDataType</a></div><div class="ttdeci">HandleDataType</div><div class="ttdef"><b>Definition:</b> Tensor.hpp:40</div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
制作者 &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.15
</small></address>
</body>
</html>
